/**
 * 
 */
package com.ctg.payroll2.action.sysadmin;

import java.sql.SQLException;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.googlecode.jsonplugin.annotations.JSON;
import com.opensymphony.xwork2.ActionSupport;

import com.ctg.platform.util.Parse;
import com.ctg.payroll2.bean.po.PbSysparmDetail;
import com.ctg.payroll2.service.sysadmin.SystemParametersDetailService;
/**
 * @author 郑致力
 *
 */
public class SystemParametersDetailAction extends ActionSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Boolean success;
	private List<PbSysparmDetail> results;
	
	private SystemParametersDetailService systemParametersDetailService;
	
	public Boolean getSuccess() {
		return success;
	}

	public void setSuccess(Boolean success) {
		this.success = success;
	}

	public List<PbSysparmDetail> getResults() {
		return results;
	}

	public void setResults(List<PbSysparmDetail> results) {
		this.results = results;
	}
	@JSON(serialize = false)
	public SystemParametersDetailService getSystemParametersDetailService() {
		return systemParametersDetailService;
	}

	public void setSystemParametersDetailService(
			SystemParametersDetailService systemParametersDetailService) {
		this.systemParametersDetailService = systemParametersDetailService;
	}

	
	public String getSystemParametersDetail() {
		Integer id = null;
		
		HttpServletRequest request = ServletActionContext.getRequest();
		id = Parse.toInteger(request.getParameter("id"));
		
		if (id == null) {
			success = false;
		} else {
			try {
				results = systemParametersDetailService.getSystemParameters(id);
				success = true;
			} catch (SQLException sqle) {
				success = false;
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		
		return SUCCESS;
	}

	/*
	 * 根据bean名称获取系统下拉列表参数
	 *  @author windy 2009-09-10
	 */
	public String getSysParamDetailByBeanName(){
		String beanName = null;
		
		HttpServletRequest request = ServletActionContext.getRequest();
		if(request.getParameter("beanName") != null)
			beanName = request.getParameter("beanName").toString();
		
		if (beanName == null) {
			success = false;
		} else {
			try {
				results = systemParametersDetailService.getSystemParameters(beanName);
				success = true;
			} catch (SQLException sqle) {
				success = false;
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		
		return SUCCESS;
		
	}
}
